import { request } from 'umi';

// 获取文章列表
export function getArticleList(page: number = 1) {
  let params = {
    page,
    pageSize: 12,
    status: 'publish',
  };
  return request('/api/article', {
    params,
  });
}
// 获取文章详情
export function getArticleDetail(id: string) {
  return request(`/api/article/${id}`);
}
// 文章管理
export function getCategoryList() {
  return request(`/api/category`);
}
// 文章管理
export function getTagList() {
  return request(`/api/tag`);
}
// 首焦
export function getisRecommended(data: any) {
  return request(`/api/article/${data.id}`, {
    method: 'PATCH',
    data:{isRecommended: data.isRecommended,}
  });
}

// 删除
export function getArticleDel(id: string) {
  return request(`/api/article/${id}`, {
    method: 'DELETE',
  });
}
// 分类删除
export function getCategoryDel(id: string) {
  return request(`/api/category/${id}`, {
    method: 'DELETE',
  });
}
// 标签删除
export function getTagDel(id: string) {
  return request(`/api/tag/${id}`, {
    method: 'DELETE',
  });
}
// 分类保存
export function getCategorySave(data: any) {
  return request(`/api/category`, {
    method: 'POST',
    data:{
      label:data.label,
      value:data.value
    }
  });
}
// 标签保存
export function getTagSave(data: any) {
  return request(`/api/tag`, {
    method: 'POST',
    data:{
      label:data.label,
      value:data.value
    }
  });
}
